//
//  PriceBlockView.swift
//  E-CycleForShop
//
//  Created by enghou on 17/4/21.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

import UIKit

class PriceBlockView: UIView {

    init(frame: CGRect,price : String) {
        super.init(frame: frame)
        self.backgroundColor = UIColor.colorWithHexString(hex: "3cc282")
        self.layer.cornerRadius = YXButtonCorner
        //结算标签
        configSubViews(price: price)
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        configSubViews(price: "")
    }
    
    func configSubViews(price : String) -> Void {
        let JSLabel = UILabel.init()
        JSLabel.textColor = UIColor.white
        JSLabel.font = UIFont.systemFont(ofSize: 36 * YXWidthScale)
        JSLabel.text = "结算价:"
        let size = "结算价:".StringSize(font: JSLabel.font)
        JSLabel.frame = CGRect.init(origin: CGPoint.init(x: 36 * YXWidthScale, y: 28 * YXHeightScale), size: size)
        self.addSubview(JSLabel)
        
        let PriceLabel = UILabel.init()
        PriceLabel.textColor = UIColor.white
        PriceLabel.font = UIFont.systemFont(ofSize: 108 * YXWidthScale)
        if price != "" {
            PriceLabel.text = "¥" + price
        } else {
            PriceLabel.text = "¥0.00"
        }
        let priceSize = PriceLabel.text!.StringSize(font: PriceLabel.font)
        PriceLabel.frame = CGRect.init(origin: CGPoint.init(x: JSLabel.left(), y: JSLabel.bottom() + 70 * YXHeightScale), size: priceSize)
        self.addSubview(PriceLabel)
        
        let stateLabel = UILabel.init()
        stateLabel.textColor = UIColor.white
        stateLabel.font = UIFont.systemFont(ofSize: 32 * YXWidthScale)
        stateLabel.text = "感谢您对绿色环保做出的一份贡献"
        let stateSize = stateLabel.text!.StringSize(font: stateLabel.font)
        stateLabel.frame = CGRect.init(x: self.width() - 32 * YXWidthScale - stateSize.width, y: self.height() - stateSize.height -  28 * YXHeightScale, width: stateSize.width, height: stateSize.height)
        self.addSubview(stateLabel)
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }

}
